const videoElement = document.getElementById('audioTest');
const divContent = document.getElementById('videoContent')

if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
    const options = {
        video:true,
        audio:true
    }
    navigator.mediaDevices.getUserMedia(options).then(stream => {
        divContent.innerText = JSON.stringify(stream.getVideoTracks()[0].getSettings())
        videoElement.srcObject = stream

    }).catch(reason => {
        console.error(reason);
    })

}

const canvasElement = document.getElementById("screenshotImg")
canvasElement.width = 320
canvasElement.height = 240

document.getElementById("screenshot").onclick = e => {
    canvasElement.getContext('2d').drawImage(videoElement, 0, 0, canvasElement.width, canvasElement.height)
}